﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Check the form input</title>
</head>
<body>
<form action="" method="post">
    <label>ID:</label>
    <input type="text" name="" id="uersid" />
    <label>Password:</label>
    <input type="text" name="" id="password" />
    <input type="submit" name="" value="Sing Up" onclick="return eg.regCheck();" />
</form>

<script>
    var eg = {};
    eg.$ = function(id) {
        return document.getElementById(id);
    };

    eg.regCheck = function() {
        var uid = eg.$("usersid");
        var upwd = eg.$("password");

        if (uid.value == '') {
            alert('ID input cannot be empty.');
            return false;
        }

        if (upwd.value == '') {
            alert('Password input cannot be empty.');
            return false;
        }
        return true;
    };
</script>

</body>
</html>